from datetime import date

from django.contrib import admin
from django.utils.translation import ugettext_lazy as _

from models import *
from src.users.models import *


class PaymentsHistoryAdmin(admin.ModelAdmin):
    model = PaymentsHistory
    list_filter = ('month', ) 
    list_display = ("user", 'paid', 'month',)
    search_fields = ['user__email' , "user__mobile"]


admin.site.register(PaymentsHistory, PaymentsHistoryAdmin)
admin.site.register(MassPaymentStatus)

#from django.contrib.admin import SimpleListFilter
#class MonthListFilter(SimpleListFilter):
#    # Human-readable title which will be displayed in the
#    # right admin sidebar just above the filter options.
#    title = _('months')
#
#    # Parameter for the filter that will be used in the URL query.
#    parameter_name = 'monath'
#
#    def lookups(self, request, model_admin):
#        """
#        Returns a list of tuples. The first element in each
#        tuple is the coded value for the option that will
#        appear in the URL query. The second element is the
#        human-readable name for the option that will appear
#        in the right sidebar.
#        """
#        return (
#            ('jan', _('january')),
#            ('feb', _('february')),
#            ('mar', _('march')),
#            ('apr', _('april')),
#            ('may', _('may')),
#            ('june', _('june')),
#            ('july', _('july')),
#            ('aug', _('august')),
#            ('sep', _('september')),
#            ('oct', _('october')),
#            ('nov', _('november')),
#            ('dec', _('december')),
#        )
#    
#    def queryset(self, request, queryset):
#        """
#        Returns the filtered queryset based on the value
#        provided in the query string and retrievable via
#        `self.value()`.
#        """
#        # Compare the requested value (either '80s' or 'other')
#        # to decide how to filter the queryset.
#        from datetime import date
#        current_year = date.today().year
#        if self.value() == 'jan':
#            return queryset.filter(month__gte=date(current_year, 1, 25),
#                                    month__lte=date(current_year, 1, 30))
#        if self.value() == 'feb':
#            return queryset.filter(month__gte=date(current_year, 2, 25),
#                                    month__lte=date(current_year, 2, 29))
#        if self.value() == 'mar':
#            return queryset.filter(month__gte=date(current_year, 3, 25),
#                                    month__lte=date(current_year, 3, 30))
#        if self.value() == 'apr':
#            return queryset.filter(month__gte=date(current_year, 4, 25),
#                                    month__lte=date(current_year, 4, 30))
#        if self.value() == 'may':
#            return queryset.filter(month__gte=date(current_year, 5, 25),
#                                    month__lte=date(current_year, 5, 30))
#        if self.value() == 'june':
#            return queryset.filter(month__gte=date(current_year, 6, 25),
#                                    month__lte=date(current_year, 6, 30))
#        if self.value() == 'july':
#            return queryset.filter(month__gte=date(current_year, 7, 25),
#                                    month__lte=date(current_year, 7, 30))
#        if self.value() == 'aug':
#            return queryset.filter(month__gte=date(current_year, 8, 25),
#                                    month__lte=date(current_year, 8, 30))
#        if self.value() == 'sep':
#            return queryset.filter(month__gte=date(current_year, 9, 25),
#                                    month__lte=date(current_year, 9, 30))
#        if self.value() == 'oct':
#            return queryset.filter(month__gte=date(current_year, 10, 25),
#                                    month__lte=date(current_year, 10, 30))
#        if self.value() == 'nov':
#            return queryset.filter(month__gte=date(current_year, 11, 25),
#                                    month__lte=date(current_year, 11, 30))
#        if self.value() == 'dec':
#            return queryset.filter(month__gte=date(current_year, 12, 25),
#                                    month__lte=date(current_year, 12, 30))